package com.warm.micro.consumer.feign;

import com.warm.micro.common.vo.Resp;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Service;

/**
 * @Date: 2020/5/9 11:46
 * @Author: LChuang
 * @Description: ProviderHystrixApi 服务降级工厂
 */
@Service
public class ProviderFallbackFactory implements FallbackFactory<ProviderFeignApi> {

    /** 泛型不填具体类型 */
    /*@Override
    public Object create(Throwable throwable) {
        return new ProviderFeignApi() {
            @Override
            public Resp<String> hello(String msg) {
                return Resp.success("provider.hello() 服务降级工厂 -- 降级 : " + msg);
            }
        };
    }*/

    @Override
    public ProviderFeignApi create(Throwable throwable) {
        return new ProviderFeignApi(){
            @Override
            public Resp<String> hello(String msg) {
                return Resp.success("provider.hello() 服务降级工厂 -- 降级 : " + msg);
            }
        };
    }
}
